fix: Retry flags only on transport errors#708
Conversation
|
Reviews (1): Last reviewed commit: "fix: retry flags only on transport error..." | Re-trigger Greptile |
| # Status codes that indicate transient server errors worth retrying | ||
| RETRY_STATUS_FORCELIST = [408, 500, 502, 503, 504] |
There was a problem hiding this comment.
idk if that was intentional and why not all the other sdks do that, so i am assuming we should remove it and just retry for transient errors which is what all sdks should do
if all sdks should retry for those http errors as well, then i'd port this to all the other sdks
There was a problem hiding this comment.
@PostHog/team-feature-flags ?
There was a problem hiding this comment.
not based on this recent change https://github.com/PostHog/posthog-ruby/pull/198/changes that should also retry on those http errors, if that was intentional
either python or ruby are the best approach, we can decide and port the best approach across sdks
…y-20260628 # Conflicts: # posthog/request.py
|
@PostHog/team-feature-flags ping |
💡 Motivation and Context
Align Python
/flags/?v=2retry behavior with the other SDK fixes: retry only bounded network/transport/timeout failures, and do not retry HTTP/API status responses like 408, 429, or 5xx.This keeps transient network handling while avoiding repeated requests when PostHog has already returned an API response.
💚 How did you test it?
uv run --extra test --extra dev ruff check posthog/request.py posthog/client.py posthog/__init__.py posthog/test/test_request.py posthog/test/test_client.pyuv run --extra test --extra dev python .github/scripts/check_public_api.pyuv run --extra test pytest posthog/test/test_request.py posthog/test/test_client.py📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with pi. The retry policy was changed from urllib3 status-code retries to explicit
/flagstransport retries, with default max retries set to 1,0disabling retries, and exponential backoff starting at 300ms.